###### Replication Package for Carter, P. & Pop-Eleches, G., 2024: "Territorial Loss and Nationalist Populism" ###################

All code needed to replicate the analyses in the main paper and online appendix can be found in the /Code/ directory.
All data, including intermediate and cleaned data products, is located in the /Data/ directory. This directory also includes the file populist_coding.xlsx, which contains aggregated indicators for party-level populism coding and replicates Table F.2.

Replication files can be run in order, from 00 to 05. A brief description of each file follows:

00-data_prep.R: This file constructs secondary variables from the raw data, excludes inattentive respondents, provides informative variable names, discards additional variables not used in the analysis, and performs other miscellaneous data cleaning tasks.
01-mi.R This file creates multiple imputation datasets from the cleaned data for use in subsequent analysis. This is somewhat time consuming and can be skipped, since the imputed data is already saved in the Data/ directory.
02-spatial_analysis.R This file produces maps of the distribution of territorial loss and replicates Figures 2 and 3.
03-paper_tables_main.R This file reproduces all of the main analysis in the paper, as well as the full specification tables in Appendix C.
04-appendix_tables.R This file reproduces the additional analyses on disentangling nationalism and populism (Appendix A) and heterogeneity by territory named (Appendix B).

All figures are saved into the Figures subdirectory, while tables are printed directly to console in Latex format from within the replication files.
Full descriptions of additional variables from survey items not included in the analysis are available upon request from the corresponding author.
All analyses were conducted using R version 4.4.1 with the most current versions of the listed packages as of 10/30/2024.